<?php  
/**
* The controller of activation of the accounting record
* Контроллер активации учетной записи.
* @author IT studio IRBIS-team
* @copyright © 2009 IRBIS-team
*/
/////////////////////////////////////////////////////////

/**
* Generation of page of an error at access out of system
* Генерация страницы ошибки при доступе вне системы
*/
    if(!defined('IRB_KEY'))
    {
       header("HTTP/1.1 404 Not Found");      
       exit(file_get_contents('../../404.html'));
    }    
//////////////////////////////////////////////////////////

/**
* We connect a file of the MySQL functions
* Подключаем файл функций MySQL
*/  
   include './libs/mysql.php'; 


   $error = true;

    if($ok && !empty($POST['value3']))
    { 
                    
            include './modules/register/functions.php';
        
            if($user_data = getLogin($POST['value3'], true))
            {
    
                mysqlQuery("UPDATE `". IRB_DBPREFIX ."user`   
                            SET  `activate` = 1  
                            WHERE `id` = '". $user_data['id'] ."'  
                           ") ;    
                                   
                $_SESSION['user_data'] = $user_data;                
                
                
           if($POST['value4'])               
               setAutologin($_SESSION['user_data']['id']);
                    
// Удаляем устаревшие записи
           $res = mysql_query("DELETE FROM `". IRB_DBPREFIX ."user` 
                               WHERE `activate` != 1
                               AND `date` < NOW() - INTERVAL 10 DAY
                              ");                    
                    
                    
                redirect('rem=office', 'id=0');
            }
            else
               $info[] = IRB_LANG_INVLID_CODE;
             
    }
    
    
 $info[] = IRB_LANG_MAIL_FOR . (isset($_SESSION['email'])?$_SESSION['email']:'') . IRB_LANG_MAIL_END;    